package cn.kimming.rpc.remoting.server;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.ConcurrentHashMap;

/**
 * 使用模板方法设计模式定义一个Rpc Server的启动和关闭
 */
public abstract class AbstractRpcServer {
	private static final Logger logger = LoggerFactory.getLogger(AbstractRpcServer.class);

	protected ServiceMap serviceMap;
	protected int port;
	protected String registryUrl;
	protected AbstractNetworkServer networkServer;
	protected static ConcurrentHashMap<String, String> registerdServiceMap = new ConcurrentHashMap<>();  // 记录注册的服务名称和其id

	protected abstract void start();

	protected abstract void shutdown();

	protected abstract void scanAllRpcService();

	protected abstract void registerServices();

	protected abstract void startNetworkServer();

	public static ConcurrentHashMap<String, String> getRegisterdServiceMap() {
		return registerdServiceMap;
	}
}
